
from flask import jsonify
from typing import Any, Optional, Union, List, Dict


def success_response(msg = "操作成功", data=None):

    if data is None:
        data = []
    response_data = {
        "success": True,
        "msg": msg,
        "data": data if data is not None else [],
        "error": ""
    }
    return jsonify(response_data)


def error_response(msg: str = "操作失败", error: str = ""):

    response_data = {
        "success": False,
        "msg": msg,
        "data": [],
        "error": error
    }
    return jsonify(response_data)
